/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerdefence.view;

import java.awt.Color;
import java.util.List;
import javax.media.opengl.GL;
import net.phys2d.math.Vector2f;
import static javax.media.opengl.GL.*;

/**
 *
 * @author Andreas
 */
class GLBackgroundRenderer {
    
    private static float[] groundColor = Color.ORANGE.getRGBComponents(null);
    
    protected static void drawBackground(GL gl, List<Vector2f> groundControlPoints, float width, float height) {
        gl.glDisable(GL_BLEND);
        gl.glPushMatrix();
        gl.glLoadIdentity();
        gl.glBegin(GL_QUADS);
        {
            gl.glColor3f(0.0f, 0.0f, 0.8f);
            gl.glVertex3f(0, 0, -1f);
            gl.glVertex3f(width, 0.0f, -1f);
            gl.glColor3f(0.4f, 0.4f, 1.0f);
            gl.glVertex3f(width, height, -1f);
            gl.glVertex3f(0.0f, height, -1f);
        }
        gl.glEnd();
        gl.glPopMatrix();
        gl.glEnable(GL_BLEND);
        drawGround(gl, groundControlPoints);
    }
    
    private static void drawGround(GL gl, List<Vector2f> groundControlPoints) {
        gl.glColor4fv(groundColor, 0);
        gl.glBegin(GL_LINE_STRIP);
        {
            for (Vector2f vector2f : groundControlPoints) {
                gl.glVertex2f(vector2f.getX(), vector2f.getY());
            }
        }
        gl.glEnd();
    }
}
